package com.ocom.common;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author lu
 * @description
 * @date 2020年02月18日 15:00
 */
public class AcpService {

    public static String shouQianBaTradeType(String trade_type){
        if (trade_type.equals("NATIVE")){
            return "2";
        }else if (trade_type.equals("JSAPI")){
            return "4";
        }else if (trade_type.equals("APP")){
            return "5";
        }else if (trade_type.equals("MWEB")){
            return "6";
        }else if (trade_type.equals("MWEB-JUMP")){
            return "6";
        }else {
            return "";
        }
    }

    /**
     * @author lu
     * @date 2020/7/28 9:27
     * @param:
     * @return java.lang.String
     * @description 银联的区分付款码
    */
    public static String union(String StrPayCodeType){
        if (StrPayCodeType.equals("pay.weixin.micropay")){
            //微信刷卡支付
            return "weixin";
        }else if (StrPayCodeType.equals("pay.alipay.micropay")){
            //支付宝刷卡支付
            return "alipay";
        }else if (StrPayCodeType.equals("pay.unionpay.micropay")){
            //银联支付
            return "unionpay";
        }else if (StrPayCodeType.equals("pay.jdpay.micropay")){
            //京东刷卡支付
            return "jd";
        }else if (StrPayCodeType.equals("pay.qq.micropay")){
            //QQ 钱包刷卡支付
            return "qq";
        }else if (StrPayCodeType.equals("pay.shiming.micropay")){
            //会员卡支付
            return "shiming";
        }else if (StrPayCodeType.equals("pay.bestpay.micropay")){
            //翼支付
            return "bestpay";
        }else if (StrPayCodeType.equals("pay.prepaid.micropay")){
            //行业账户支付
            return "prepaid";
        }else if (StrPayCodeType.equals("pay.brushface.micropay")){
            //银联刷脸支付
            return "brushface";
        }
        return "";
    }


    /**
     * @author lu
     * @date 2020/2/18 15:01
     * @param: authcode
     * @return int
     * @description 区分付款码
    */
    public static String thirdtyp(String authcode){
        //微信的正则表达式
        String wx="^1[0-5]\\d{16}$";
        //支付宝的正则表达式
        String zhifbao="^(?:2[5-9]|30)\\d{14,18}$";
        //银联的正则表达式
        String yinlian="^62\\d{16,22}$";
        //百度钱包的正则表达式
        String baifubao="^31\\d{0,20}$";
        //数字人民币
        String eCNY="^01005\\d{13,22}$";
        if (SDKUtil.isCode(authcode,wx)){
            return "weixin";
        }else if (SDKUtil.isCode(authcode,zhifbao)){
            return "alipay";
        }else if (SDKUtil.isCode(authcode,yinlian)){
            return "unionpay";
        }else if (SDKUtil.isCode(authcode,baifubao)){
            return "baifubao";
        }else if (SDKUtil.isCode(authcode,eCNY)){
            return "E-CNY";
        }else if (authcode.startsWith("JHSH")){
            return "JHSH";//建行生活
        }
        return "";
    }

    public static String qingDaoNongShangCode(String authcode){
        //微信的正则表达式
        String wx="^(10|11|12|13|14|15)\\d{16}$";
        //支付宝的正则表达式
        String zhifbao="^(25|26|27|28|29|30)\\d{14,22}$";
        //银联的正则表达式
        String yinlian="^62\\d{16,22}$";
        //百度钱包的正则表达式
        String baifubao="^31\\d{0,20}$";
        if (SDKUtil.isCode(authcode,wx)){
            return "1";
        }else if (SDKUtil.isCode(authcode,zhifbao)){
            return "2";
        }
        return "";
    }

    public static String qingDaoNongShangCodes(String authcode){
        //微信的正则表达式
        if (authcode.equals("weixin")){
            return "1";
        }else if (authcode.equals("alipay")){
            return "2";
        }
        return "";
    }
    /**
     * @author lu
     * @date 2020/2/18 15:01
     * @param: authcode
     * @return int
     * @description 龙支付区分付款码
     */
    public static String countType(String authcode){
        //微信的正则表达式
        String wx="^(10|11|12|13|14|15)\\d{16}$";
        //支付宝的正则表达式
        String zhifbao="^(25|26|27|28|29|30)\\d{14,22}$";
        //银联的正则表达式
        String yinlian="^62\\d{16,22}$";
        //百度钱包的正则表达式
        String baifubao="^31\\d{0,20}$";
        if (SDKUtil.isCode(authcode,wx)){
            return "2";
        }else if (SDKUtil.isCode(authcode,zhifbao)){
            return "3";
        }else if (SDKUtil.isCode(authcode,yinlian)){
            return "4";
        }
        return "";
    }
    /**
     * @author lu
     * @date 2020/3/20 13:11
     * @param: type
     * @return java.lang.String
     * @description 龙支付的
    */
    public static String ccbbType(String type){

        if (type.equals("2")){
            return "weixin";
        }else if (type.equals("3")){
            return "alipay";
        }else if (type.equals("4")){
            return "unionpay";
        }else if (type.equals("1")){
            return "ccbb";
        }
        return "";
    }

    /**
     * @author lu
     * @date 2020/3/24 14:40
     * @param: type
     * @return java.lang.String
     * @description 移领
    */
    public static String kancloudType(String type){

        if (type.equals("1")){
            //	微信
            return "weixin";
        }else if (type.equals("2")){
            //支付宝
            return "alipay";
        }else if (type.equals("3")){
            //百度钱包
            return "baifubao";
        }else if (type.equals("5")){
            //翼支付
            return "bestpay";
        }else if (type.equals("6")){
            //云闪付
            return "unionpay";
        }else if (type.equals("7")){
            //刷卡
            return "shuaka";
        }else if (type.equals("9")){
            //QQ钱包
            return "qqbao";
        }else if (type.equals("10")){
            //沃支付
            return "epay";
        }
        return "";
    }
    /**
     * @author lu
     * @date 2020/2/25 13:28
     * @param: amount
     * @return java.lang.String
     * @description 金额的转化(由分转元)
    */
    public static String stringAmount(String amount){
        BigDecimal a = new BigDecimal(amount);
        a=a.divide(new BigDecimal("100"));
        a = a.setScale(2, RoundingMode.HALF_UP);
        return a.toString();
    }

    /**
     * @author lu
     * @date 2020/2/25 13:32
     * @param: amount
     * @return java.lang.String
     * @description 金额的转化(由元转分)
    */
    public static String pointsAmount(String amount){
        BigDecimal bigDecimal = new BigDecimal(amount).setScale(2);
        int intMoney= bigDecimal.multiply(new BigDecimal(100)).intValue();
        String strMoney=String.valueOf(intMoney);
        return strMoney;
    }

    public static String suiXingPayType(String payway){
        if (payway.equals("WECHAT")){
            return "weixin";
        }else if (payway.equals("ALIPAY")){
            //支付宝
            return "alipay";
        }else if (payway.equals("UNIONPAY")){
            //银联
            return "unionpay";
        }
        return "";
    }

    /**
     * @author lu
     * @date 2020/3/10 16:33
     * @param: payway
     * @return java.lang.String
     * @description 收钱吧返回的支付方式
    */
    public static String payment(String payway){
        if (payway.equals("1")){
            //支付宝1.0 / Alipay-Local
            return "alipay";
        }else if (payway.equals("2")){
            //支付宝
            return "alipay";
        }else if (payway.equals("3")){
            //微信
            return "weixin";
        }else if (payway.equals("4")){
            //百度钱包
            return "baifubao";
        }else if (payway.equals("5")){
            //京东钱包
            return "jdbao";
        }else if (payway.equals("6")){
            //qq钱包
            return "qqbao";
        }else if (payway.equals("7")){
            //NFC支付
            return "NFCpay";
        }else if (payway.equals("8")){
            //拉卡拉钱包
            return "lakalabao";
        }else if (payway.equals("9")){
            //和包支付
            return "hebaopay";
        }else if (payway.equals("15")){
            //拉卡拉微信
            return "lakalaweixinpay";
        }else if (payway.equals("16")){
            //招商银行
            return "CMB";
        }else if (payway.equals("17")){
            //银联云闪付
            return "unionpay";
        }else if (payway.equals("18")){
            //翼支付
            return "bestpay";
        }else if (payway.equals("19")){
            //境外微信本地钱包收款
            return "weixinlocal";
        }else if (payway.equals("22")){
            //索迪斯预付卡
            return "Sodexopay";
        }else if (payway.equals("100")){
            //储值支付
            return "chuzhipay";
        }else if (payway.equals("101")){
            //礼品卡
            return "giftcard";
        }
        return "";
    }
}
